﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MegaMan2PasswordGenerator
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AboutBox1 aboutbox = new AboutBox1();

            aboutbox.ShowDialog();
        }

        private void clearPassword()
        {
            a1CheckBox.Checked = false;
            a2CheckBox.Checked = false;
            a3CheckBox.Checked = false;
            a4CheckBox.Checked = false;
            a5CheckBox.Checked = false;

            b1CheckBox.Checked = false;
            b2CheckBox.Checked = false;
            b3CheckBox.Checked = false;
            b4CheckBox.Checked = false;
            b5CheckBox.Checked = false;

            c1CheckBox.Checked = false;
            c2CheckBox.Checked = false;
            c3CheckBox.Checked = false;
            c4CheckBox.Checked = false;
            c5CheckBox.Checked = false;

            d1CheckBox.Checked = false;
            d2CheckBox.Checked = false;
            d3CheckBox.Checked = false;
            d4CheckBox.Checked = false;
            d5CheckBox.Checked = false;

            e1CheckBox.Checked = false;
            e2CheckBox.Checked = false;
            e3CheckBox.Checked = false;
            e4CheckBox.Checked = false;
            e5CheckBox.Checked = false;

        }

        private void calculatePassword()
        {
            //clear previous
            clearPassword();

            if (energyTanksComboBox.SelectedIndex == 0)
            {
                etankPictureBox.Visible = false;
                etank2PictureBox.Visible = false;
                etank3PictureBox.Visible = false;
                etank4PictureBox.Visible = false;

                a1CheckBox.Checked = true;
                a2CheckBox.Checked = false;
                a3CheckBox.Checked = false;
                a4CheckBox.Checked = false;
                a5CheckBox.Checked = false;
                

                if (airManCheckBox.Checked)
                {
                    e3CheckBox.Checked = true;
                }
                else
                {
                    d2CheckBox.Checked = true;
                }

                if (bubbleManCheckBox.Checked)
                {
                    d1CheckBox.Checked = true;
                }
                else
                {
                    c3CheckBox.Checked = true;
                }

                if (crashManCheckBox.Checked)
                {
                    c5CheckBox.Checked = true;
                }
                else
                {
                    e2CheckBox.Checked = true;
                }

                if (flashManCheckBox.Checked)
                {
                    c1CheckBox.Checked = true;
                }
                else
                {
                    e4CheckBox.Checked = true;
                }

                if (heatManCheckBox.Checked)
                {
                    b2CheckBox.Checked = true;
                }
                else
                {
                    d5CheckBox.Checked = true;
                }

                if (metalManCheckBox.Checked)
                {
                    e5CheckBox.Checked = true;
                }
                else
                {
                    e1CheckBox.Checked = true;
                }

                if (quickManCheckBox.Checked)
                {
                    b4CheckBox.Checked = true;
                }
                else
                {
                    c4CheckBox.Checked = true;
                }

                if (woodManCheckBox.Checked)
                {
                    d3CheckBox.Checked = true;
                }
                else
                {
                    b5CheckBox.Checked = true;
                }
            }
            else if (energyTanksComboBox.SelectedIndex == 1)
            {
                etankPictureBox.Visible = true;
                etank2PictureBox.Visible = false;
                etank3PictureBox.Visible = false;
                etank4PictureBox.Visible = false;

                a1CheckBox.Checked = false;
                a2CheckBox.Checked = true;
                a3CheckBox.Checked = false;
                a4CheckBox.Checked = false;
                a5CheckBox.Checked = false;

                if (airManCheckBox.Checked)
                {
                    e4CheckBox.Checked = true;
                }
                else
                {
                    d3CheckBox.Checked = true;
                }

                if (bubbleManCheckBox.Checked)
                {
                    d2CheckBox.Checked = true;
                }
                else
                {
                    c4CheckBox.Checked = true;
                }

                if (crashManCheckBox.Checked)
                {
                    d1CheckBox.Checked = true;
                }
                else
                {
                    e3CheckBox.Checked = true;
                }

                if (flashManCheckBox.Checked)
                {
                    c2CheckBox.Checked = true;
                }
                else
                {
                    e5CheckBox.Checked = true;
                }

                if (heatManCheckBox.Checked)
                {
                    b3CheckBox.Checked = true;
                }
                else
                {
                    e1CheckBox.Checked = true;
                }

                if (metalManCheckBox.Checked)
                {
                    b1CheckBox.Checked = true;
                }
                else
                {
                    e2CheckBox.Checked = true;
                }

                if (quickManCheckBox.Checked)
                {
                    b5CheckBox.Checked = true;
                }
                else
                {
                    c5CheckBox.Checked = true;
                }

                if (woodManCheckBox.Checked)
                {
                    d4CheckBox.Checked = true;
                }
                else
                {
                    c1CheckBox.Checked = true;
                }
            }
            else if (energyTanksComboBox.SelectedIndex == 2)
            {
                etankPictureBox.Visible = true;
                etank2PictureBox.Visible = true;
                etank3PictureBox.Visible = false;
                etank4PictureBox.Visible = false;

                a1CheckBox.Checked = false;
                a2CheckBox.Checked = false;
                a3CheckBox.Checked = true;
                a4CheckBox.Checked = false;
                a5CheckBox.Checked = false;

                if (airManCheckBox.Checked)
                {
                    e5CheckBox.Checked = true;
                }
                else
                {
                    d4CheckBox.Checked = true;
                }

                if (bubbleManCheckBox.Checked)
                {
                    d3CheckBox.Checked = true;
                }
                else
                {
                    c5CheckBox.Checked = true;
                }

                if (crashManCheckBox.Checked)
                {
                    d2CheckBox.Checked = true;
                }
                else
                {
                    e4CheckBox.Checked = true;
                }

                if (flashManCheckBox.Checked)
                {
                    c3CheckBox.Checked = true;
                }
                else
                {
                    b1CheckBox.Checked = true;
                }

                if (heatManCheckBox.Checked)
                {
                    b4CheckBox.Checked = true;
                }
                else
                {
                    e2CheckBox.Checked = true;
                }

                if (metalManCheckBox.Checked)
                {
                    b2CheckBox.Checked = true;
                }
                else
                {
                    e3CheckBox.Checked = true;
                }

                if (quickManCheckBox.Checked)
                {
                    c1CheckBox.Checked = true;
                }
                else
                {
                    d1CheckBox.Checked = true;
                }

                if (woodManCheckBox.Checked)
                {
                    d5CheckBox.Checked = true;
                }
                else
                {
                    c2CheckBox.Checked = true;
                }
            }
            else if (energyTanksComboBox.SelectedIndex == 3)
            {
                etankPictureBox.Visible = true;
                etank2PictureBox.Visible = true;
                etank3PictureBox.Visible = true;
                etank4PictureBox.Visible = false;

                a1CheckBox.Checked = false;
                a2CheckBox.Checked = false;
                a3CheckBox.Checked = false;
                a4CheckBox.Checked = true;
                a5CheckBox.Checked = false;

                if (airManCheckBox.Checked)
                {
                    b1CheckBox.Checked = true;
                }
                else
                {
                    d5CheckBox.Checked = true;
                }

                if (bubbleManCheckBox.Checked)
                {
                    d4CheckBox.Checked = true;
                }
                else
                {
                    d1CheckBox.Checked = true;
                }

                if (crashManCheckBox.Checked)
                {
                    d3CheckBox.Checked = true;
                }
                else
                {
                    e5CheckBox.Checked = true;
                }

                if (flashManCheckBox.Checked)
                {
                    c4CheckBox.Checked = true;
                }
                else
                {
                    b2CheckBox.Checked = true;
                }

                if (heatManCheckBox.Checked)
                {
                    b5CheckBox.Checked = true;
                }
                else
                {
                    e3CheckBox.Checked = true;
                }

                if (metalManCheckBox.Checked)
                {
                    b3CheckBox.Checked = true;
                }
                else
                {
                    e4CheckBox.Checked = true;
                }

                if (quickManCheckBox.Checked)
                {
                    c2CheckBox.Checked = true;
                }
                else
                {
                    d2CheckBox.Checked = true;
                }

                if (woodManCheckBox.Checked)
                {
                    e1CheckBox.Checked = true;
                }
                else
                {
                    c3CheckBox.Checked = true;
                }
            }
            else if (energyTanksComboBox.SelectedIndex == 4)
            {
                etankPictureBox.Visible = true;
                etank2PictureBox.Visible = true;
                etank3PictureBox.Visible = true;
                etank4PictureBox.Visible = true;

                a1CheckBox.Checked = false;
                a2CheckBox.Checked = false;
                a3CheckBox.Checked = false;
                a4CheckBox.Checked = false;
                a5CheckBox.Checked = true;

                if (airManCheckBox.Checked)
                {
                    b2CheckBox.Checked = true;
                }
                else
                {
                    e1CheckBox.Checked = true;
                }

                if (bubbleManCheckBox.Checked)
                {
                    d5CheckBox.Checked = true;
                }
                else
                {
                    d2CheckBox.Checked = true;
                }

                if (crashManCheckBox.Checked)
                {
                    d4CheckBox.Checked = true;
                }
                else
                {
                    b1CheckBox.Checked = true;
                }

                if (flashManCheckBox.Checked)
                {
                    c5CheckBox.Checked = true;
                }
                else
                {
                    b3CheckBox.Checked = true;
                }

                if (heatManCheckBox.Checked)
                {
                    c1CheckBox.Checked = true;
                }
                else
                {
                    e4CheckBox.Checked = true;
                }

                if (metalManCheckBox.Checked)
                {
                    b4CheckBox.Checked = true;
                }
                else
                {
                    e5CheckBox.Checked = true;
                }

                if (quickManCheckBox.Checked)
                {
                    c3CheckBox.Checked = true;
                }
                else
                {
                    d3CheckBox.Checked = true;
                }

                if (woodManCheckBox.Checked)
                {
                    e2CheckBox.Checked = true;
                }
                else
                {
                    c4CheckBox.Checked = true;
                }
            }
            else
            {
                MessageBox.Show("Something Broke!", "MegaMan 2 Password Generator", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            energyTanksComboBox.SelectedIndex = 0;
            etankPictureBox.Visible = false;
            etank2PictureBox.Visible = false;
            etank3PictureBox.Visible = false;
            etank4PictureBox.Visible = false;
        }

        private void energyTanksComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            calculatePassword();
        }

        private void airManCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            calculatePassword();

            if (airManCheckBox.Checked)
            {
                airmanPictureBox.Image = Properties.Resources.airmandoa;
            }
            else
            {
                airmanPictureBox.Image = Properties.Resources.airman;
            }
        }

        private void bubbleManCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            calculatePassword();

            if (bubbleManCheckBox.Checked)
            {
                bubblemanPictureBox.Image = Properties.Resources.bubbleman_doa;
            }
            else
            {
                bubblemanPictureBox.Image = Properties.Resources.bubbleman;
            }
        }

        private void crashManCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            calculatePassword();

            if (crashManCheckBox.Checked)
            {
                crashmanPictureBox.Image = Properties.Resources.crashman_doa;
            }
            else
            {
                crashmanPictureBox.Image = Properties.Resources.crashman;
            }
        }

        private void flashManCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            calculatePassword();

            if (flashManCheckBox.Checked)
            {
                flashmanPictureBox.Image = Properties.Resources.flashman_doa;
            }
            else
            {
                flashmanPictureBox.Image = Properties.Resources.flashman;
            }
        }

        private void heatManCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            calculatePassword();

            if (heatManCheckBox.Checked)
            {
                heatmanPictureBox.Image = Properties.Resources.heatman_doa;
            }
            else
            {
                heatmanPictureBox.Image = Properties.Resources.heatman;
            }
        }

        private void metalManCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            calculatePassword();

            if (metalManCheckBox.Checked)
            {
                metalmanPictureBox.Image = Properties.Resources.metalman_doa;
            }
            else
            {
                metalmanPictureBox.Image = Properties.Resources.metalman;
            }
        }

        private void quickManCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            calculatePassword();

            if (quickManCheckBox.Checked)
            {
                quickmanPictureBox.Image = Properties.Resources.quickman_doa;
            }
            else
            {
                quickmanPictureBox.Image = Properties.Resources.quickman;
            }
        }

        private void woodManCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            calculatePassword();

            if (woodManCheckBox.Checked)
            {
                woodmanPictureBox.Image = Properties.Resources.woodman_doa;
            }
            else
            {
                woodmanPictureBox.Image = Properties.Resources.woodman;
            }
        }

        private void clearToolStripMenuItem_Click(object sender, EventArgs e)
        {
            energyTanksComboBox.SelectedIndex = 0;
            clearPassword();
            airManCheckBox.Checked = false;
            bubbleManCheckBox.Checked = false;
            crashManCheckBox.Checked = false;
            flashManCheckBox.Checked = false;
            heatManCheckBox.Checked = false;
            metalManCheckBox.Checked = false;
            quickManCheckBox.Checked = false;
            woodManCheckBox.Checked = false;

        }


    }
}
